package cn.jlearn.proxy.server;

import cn.jlearn.proxy.common.container.SwitchContainer;
import cn.jlearn.proxy.common.pojo.Constant;
import cn.jlearn.proxy.server.container.ForwardServer;
import cn.jlearn.proxy.server.container.ProxyServer;
import cn.jlearn.proxy.common.utils.PropertiesUtil;

import java.util.Arrays;
import java.util.List;

/**
 * @author qianyingchao
 * @version 1.0
 * @date 2021/5/8 5:55 下午
 */
public class ServerStartApp {

    public static void main(String[] args) {

        List<SwitchContainer> containers = Arrays.asList(
                new ProxyServer(PropertiesUtil.getProperty("proxy.host", "0.0.0.0"), Integer.parseInt(PropertiesUtil.getProperty("proxy.port"))),
                new ForwardServer(PropertiesUtil.getProperty("forward.host", "0.0.0.0"), Integer.parseInt(PropertiesUtil.getProperty("forward.port")))
        );

        for (SwitchContainer container : containers) {
            Constant.SERVER_START_THREAD_POOL.execute(container::start);
        }

    }

}